﻿using System;
using System.Windows.Automation;

namespace QuickUIT.Controls
{
    /// <summary>
    /// Represents a radio button control. 
    /// </summary>
    public class UIRadioButton : UIBaseControl
    {
        /// <summary>
        /// Gets whether the current radio button is selected. 
        /// </summary>
        public new bool IsSelected
        {
            get { return base.IsSelected; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIRadioButton"/> class. 
        /// </summary>
        public UIRadioButton() : base(ControlType.RadioButton)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIRadioButton"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UIRadioButton(UIBaseControl parent) : base(parent, ControlType.RadioButton)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIRadioButton"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIRadioButton(string locator) : base(null, ControlType.RadioButton, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIRadioButton"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIRadioButton(UIBaseControl parent, string locator) : base(parent, ControlType.RadioButton, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIRadioButton"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIRadioButton(AutomationElement control) : base(control, ControlType.RadioButton)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIRadioButton"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIRadioButton(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.RadioButton)
        {
        }

        /// <summary>
        /// Deselects any selected items and then selects the radio button.
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void Select()
        {
            base.Select();
        }

        /// <summary>
        /// Adds the current element to the collection of selected items. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void AddToSelection()
        {
            base.AddToSelection();
        }

        /// <summary>
        /// Removes the current element to the collection of selected items. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void RemoveFromSelection()
        {
            base.RemoveFromSelection();
        }

        /// <summary>
        /// Gets the parent selection container of the radio button. 
        /// </summary>
        /// <returns>The <see cref="AutomationElement"/> of the parent control that implements the <see cref="SelectionPattern"/>.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement GetSelectionContainer()
        {
            return base.GetSelectionContainer(); 
        }
    }
}
